package com.jinyu.jyly.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jinyu.jyly.R;
import com.jinyu.jyly.bean.MineBuyOrderInfo;

import java.util.List;


/**
 *
 */
public class MinePageOrderTabAdapter extends BaseQuickAdapter<MineBuyOrderInfo.DataBean, BaseViewHolder> {

    public MinePageOrderTabAdapter(List<MineBuyOrderInfo.DataBean> data, int layoutResIds) {
        super(layoutResIds, data);
    }


    @Override
    protected void convert(final BaseViewHolder helper, final MineBuyOrderInfo.DataBean item) {

        helper.setText(R.id.tv_title, item.getName());
        helper.setText(R.id.tv_price, item.getPrice() + "");
        helper.setText(R.id.tv_num, item.getNum() + "");
        helper.setText(R.id.tv_num_01, "共" + item.getNum() + "件产品");
        helper.setText(R.id.tv_all_price, "￥" + item.getPrice());
        helper.addOnClickListener(R.id.tv_go_shouhuo);


        RequestOptions options = new RequestOptions();
        options.error(R.mipmap.space_list);
        Glide.with(mContext).load(item.getThumb())
                .apply(options)
                .into((ImageView) helper.getView(R.id.iv_img));

        LinearLayout ll_bottom = helper.getView(R.id.ll_bottom);

        int status = item.getStatus();
        switch (status) {
            case 0:
                //待入场
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待入场");
                break;
            case 1:
                //待被买
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待被买");
                break;
            case 2:
                //已锁单
                ll_bottom.setVisibility(View.VISIBLE);
                helper.setText(R.id.tv_order_state, "待付款");
                break;
            case 3:
                //已付款
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已付款");
                break;
            case 4:
                //已确认收款
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已确认收款");
                break;
            case 5:
                //已完成
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已完成");
                break;
            case 6:
                //已取消
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已取消");
                break;
            case 7:
                //待发货
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待发货");
                break;
            case 8:
                //待收货
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "待收货");
                break;
            case 9:
                //已收货
                ll_bottom.setVisibility(View.GONE);
                helper.setText(R.id.tv_order_state, "已收货");
                break;

        }
    }


}


